package ik;

import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;

import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;

public class ConfigurationExemple {
    public static void main(String[] args) {
        Configuration configuration=new Configuration();
        //configuration.setTemplateLoader(new StringTemplateLoader());
        configuration.setDefaultEncoding("utf-8");
        HashMap<String, Object> map = new HashMap<>();
        map.put("a", 9);
        map.put("b", 142);
        String model = "${(a/b*100)?string('0')}%";
        try {
            Template template = new Template("1", model, configuration);
            StringWriter writer = new StringWriter();
            template.process(map, writer);
            //打印
            System.out.println(writer.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }



    }
}
